package cn.han.File;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

/**/
public class TestFile {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\ready\\1.txt");
        System.out.println(file.length());
        System.out.println(file.exists());//判断文件是否存在
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file.getName());
        System.out.println(file.getParent());
        System.out.println(file.getAbsolutePath());//获取完整路径:绝对路径
        file = new File("D:\\ready\\2.txt");
        file.createNewFile();
        file = new File("D:\\ready\\m");
        System.out.println(file.mkdir());
        file = new File("D:\\ready\\m\\a\\b\\c");
        System.out.println(file.mkdirs());
        System.out.println(file.delete());
        file = new File("D:\\ready\\2.txt");
        System.out.println(file.delete());
        file = new File("D:\\ready");
        System.out.println(Arrays.toString(file.list()));
        System.out.println(Arrays.toString(file.listFiles()));
    }
}
